#include<stdio.h>
#include<sys/shm.h>
#include<fcntl.h>
#include<string.h>
int main(){
    //创建共享内存
    int shm_id = shmget(0x23232323, 1024, IPC_CREAT | 0664);
    if(shm_id < 0){
        perror("shmget");
        return 0;
    }
    //附加
    void* addr = shmat(shm_id, NULL, 0);
    if(addr == NULL){
        perror("shmat");
        return 0;
    }
    //写
    const char* str = "I am write Process";
    strcpy((char*)addr, str);
    //分离
    shmdt(addr);
    return 0;
}

